package com.joinval.modules.sys.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.joinval.common.utils.PageUtils;
import com.joinval.common.utils.Query;
import com.joinval.modules.sys.dao.SysRuleDao;
import com.joinval.modules.sys.entity.SysRule;
import com.joinval.modules.sys.service.SysRuleService;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;


@Service("sysRuleService")
public class SysRuleServiceImpl extends ServiceImpl<SysRuleDao, SysRule> implements SysRuleService {

    @Override
    public PageUtils queryPage(Map<String, Object> params) {
        IPage<SysRule> page = this.page(
                new Query<SysRule>().getPage(params),
                new QueryWrapper<SysRule>()
        );

        return new PageUtils(page);
    }

    @Override
    public List<SysRule> rules() {
        QueryWrapper<SysRule> sysRuleQueryWrapper = new QueryWrapper<>();
        sysRuleQueryWrapper.orderByAsc("line_no");
        return this.baseMapper.selectList(sysRuleQueryWrapper);
    }

}
